//!
//! Copyright (c) 2024-2999 北京心月狐科技有限公司 All rights reserved.
//!
//! https://www.mxxshop.com
//!
//! Licensed 并不是自由软件，未经许可不能去掉 MxxShop 相关版权
//!
//! 版权所有，侵权必究！
//!


use rbatis::{crud, impl_select_page};
use crate::modules::product::entity::spec_entity::{SpecBase, SpecTemplate, SpecType, SpecValue};
use crate::modules::product::entity::spec_model::QueryPagePO;

crud!(SpecBase {}, "mxx_product_spec_base");


crud!(SpecTemplate {}, "mxx_product_spec_template");

impl_select_page!(SpecTemplate{select_by_page(dto: &QueryPagePO) =>"
    trim end=' where ':
      ` where `
      trim ' and ':
        if dto.template_name != null && dto.template_name != '':
          ` and template_name like '%${dto.template_name}%'`
        if dto.category_id != null && dto.category_id != '':
          ` and category_id = #{dto.category_id} `
        choose:
          when dto.is_enable == 0:
            ` and is_enable >= 0 `
          when dto.is_enable == 1:
            ` and is_enable = 0 `
          when dto.is_enable == 2:
            ` and is_enable = 1 `
    if !sql.contains('count'):
      ` order by id desc `"},"mxx_product_spec_template");


crud!(SpecType {}, "mxx_product_spec_type");





crud!(SpecValue {}, "mxx_product_spec_value");


